<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/WEB-INF/template/globalTemplate.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="title">
        #{msg['application.titre.administration.salle']}
    </ui:define>
    
    <ui:define name="ariane">
        <h:commandLink action="/index.xhtml"  > Accueil </h:commandLink> > Salles
    </ui:define>

    <ui:define name="content">
        
        <h:panelGroup styleClass="titre">Liste des salles</h:panelGroup>
        
        <p:commandLink styleClass="lienAction lienCreer"
                       value="#{msg['application.creer']} une salle"
                       action="#{adminSalleBean.creer()}"
                       update="popup"   />
        
        <p:dataTable value="#{adminSalleBean.listSalle}" var="salle" id="dataTableListeSalle">
            <p:column headerText="Libellé">
                <h:outputText value="#{salle.libPiece}"/>
            </p:column>
            <p:column headerText="Nombre de place">
                <h:outputText value="#{salle.nbPlace}"/>
            </p:column>
            <p:column headerText="Description">
                <h:outputText value="#{salle.description}"/>
            </p:column>
            <p:column headerText="Actions">
                <p:commandLink action="#{adminSalleBean.modifier(salle)}"
                               value="Modifier"
                               update="globalForm:popup"  />
                &nbsp;
                <p:commandLink action="#{adminSalleBean.supprimer(salle)}"
                               value="Supprimer"
                               update="globalForm:confirm"  />
            </p:column>
        </p:dataTable>
        
        <p:commandLink styleClass="lienAction lienCreer"
                       value="#{msg['application.creer']} une salle"
                       action="#{adminSalleBean.creer()}"
                       update="popup"  />
        
    </ui:define>
    
    <ui:define name="popup">
        <h:panelGrid columns="3">
            <h:outputLabel for="inputLibelle"
                           value="Libellé (N°bat-N°piece) :"/>
            <p:inputText value="#{adminSalleBean.salle.libPiece}" id="inputLibelle"
                          />
            <p:message for="inputLibelle"/>
            
            <h:outputLabel for="spinnerBasic" value="Nombre de place :"/>
            <p:spinner id="spinnerBasic"   
                       value="#{adminSalleBean.salle.nbPlace}" min="1"/>
            <p:message for="spinnerBasic"/>
            
            <h:outputLabel for="InputTextarea" value="Description :"/>
            <h:inputTextarea id="InputTextarea" rows="8"  value="#{adminSalleBean.salle.description}"/>
            <p:message for="InputTextarea"/>
            
        </h:panelGrid>
        <h:panelGrid columns="2">
            <p:commandButton value="Créer"
                             onclick="popup.hide()"
                             action="#{adminSalleBean.validerCreer}"
                             rendered="#{adminSalleBean.modeCreation}"
                             update="dataTableListeSalle messages"/>
            <p:commandButton value="Modifier"
                             onclick="popup.hide()"
                             action="#{adminSalleBean.validerModifier}"
                             rendered="#{!adminSalleBean.modeCreation}"
                             update="dataTableListeSalle messages"/>
            <p:commandButton value="Annuler" onclick="popup.hide()"
                             action="#{adminSalleBean.annuler}"/>
        </h:panelGrid>
    </ui:define>

</ui:composition>
